package com.alibaba.mapper;

import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

@Mapper
@Repository
public interface PostLikeMapper {

    @Update(value = "update forum set forum.likeNum=forum.likeNum+1 where forum.forumId=#{forumId}")
    void postLikeInc(int forumId);

    @Update(value = "update forum set forum.likeNum=forum.likeNum-1 where forum.forumId=#{forumId}")
    void postLikeDec(int forumId);

    @Select(value = "select f.likeNum from forum f where f.forumId=#{forumId}")
    int num(int forumId);

    @Insert(value = "insert into islike(userId,forumId) values(#{userId},#{forumId})")
    void insertLike(int userId, int forumId);

    @Delete(value = "delete from islike where islike.userId=#{userId} and islike.forumId=#{forumId}")
    void deleteLike(int userId, int forumId);

}
